package com.hut.oa.model.bean;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="discuss_vote_select_content")
public class DiscussVoteSelectContent {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="vsc_id")
	private Long id;
	
	@Column(name="vsc_content",nullable=false)
	private String vcontent;//投票选项内容
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="v_id")
	private DiscussVote vote;//对应投票帖
	
	@JsonIgnore
	@ManyToMany(cascade=CascadeType.REFRESH,fetch = FetchType.LAZY)
	@JoinTable(name = "discuss_vscontent_user",
	    joinColumns = {
	            @JoinColumn(name = "dvsc_content_id")
	    }, inverseJoinColumns = {
	    @JoinColumn(name = "dvu_user_id")
	})
	private List<User> users;//对应多个用户
	
	public DiscussVoteSelectContent() {}
	
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	
	public DiscussVote getVote() {
		return vote;
	}
	public void setVote(DiscussVote vote) {
		this.vote = vote;
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getVcontent() {
		return vcontent;
	}
	public void setVcontent(String vcontent) {
		this.vcontent = vcontent;
	}
	@Override
	public String toString() {
		return "VoteSelectContent [id=" + id + ", vcontent=" + vcontent + ", vote=" + vote + "]";
	}
	

}
